#include "MonitoringMainData.h"
#include "ui_MonitoringMainData.h"
#include <QDebug>
MonitoringMainData::MonitoringMainData(QWidget *parent,deviceModel*dmodel,userModel*umodel) :
    QWidget(parent),
    ui(new Ui::MonitoringMainData),
    dmodel(dmodel),
    umodel(umodel)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose, true); // 设置关闭时删除对象
    p_real=new MonitoringRealData(this,dmodel,umodel);
    p_history=new MonitoringHistoryData(this,umodel);
    p_warn=new WarnRuleSet(this,dmodel,umodel);
    ui->stackedWidget->addWidget(p_real);
    ui->stackedWidget->addWidget(p_history);
    ui->stackedWidget->addWidget(p_warn);
    ui->stackedWidget->setCurrentWidget(p_real);

    connect(ui->pushButton_1,&QPushButton::clicked,this,[=](){
        ui->stackedWidget->setCurrentIndex(0);
    });
    connect(ui->pushButton_2,&QPushButton::clicked,this,[=](){
        ui->stackedWidget->setCurrentIndex(1);
    });
    connect(ui->pushButton_3,&QPushButton::clicked,this,[=](){
        ui->stackedWidget->setCurrentIndex(2);
    });
}

MonitoringMainData::~MonitoringMainData()
{
    qDebug()<<"父销毁";
    delete ui;
}
